<?php

include_once("functions/db_manipulate.php");
if (!init()) {
    redirect('login.php');
}

$link_id = connectDB();


if ($_GET['like'] != '') {
    $checkLikeResultSet = mysql_query("INSERT INTO likes(userid, indicator, contentid)
                                       VALUES (
                                               '" . $_SESSION['id'] . "',
                                               'g',
                                               '" . $_GET['cid'] . "')");
    if ($checkLikeResultSet) {
        $resultSet = mysql_query("UPDATE galcomments SET `likes` = `likes` + 1
                              WHERE
                                     id='" . mysql_real_escape_string($_GET['cid']) . "'") or die(mysql_error());
    }
} else if ($_GET['dislike'] != '') {
    $checkDislikeResultSet = mysql_query("INSERT INTO dislikes(userid, indicator, contentid)
                                       VALUES (
                                               '" . $_SESSION['id'] . "',
                                               'g',
                                               '" . $_GET['cid'] . "')");
    if ($checkDislikeResultSet) {
        $resultSet = mysql_query("UPDATE galcomments SET `dislikes` = `dislikes` + 1
                              WHERE
                                     id='" . mysql_real_escape_string($_GET['cid']) . "'") or die(mysql_error());
    }
}
redirect($_SERVER['HTTP_REFERER']);
